package twoPointers;

//https://leetcode.cn/problems/container-with-most-water/description/
public class l_11 {
    //左右双指针, 谁小移动谁
    public int maxArea(int[] height) {
        int n = height.length, left = 0, right = n - 1, ans = 0;
        while(left < right) {
            int res = Math.min(height[left], height[right]) * (right - left);
            ans = Math.max(ans, res);
            if(height[left] < height[right]) ++left;
            else --right;
        }
        return ans;
    }
}
